feat(agent): add order field for configurable agent cycling order#24689
feat(agent): add order field for configurable agent cycling order#24689LCubero wants to merge 1 commit intoanomalyco:devfrom
Conversation
Adds an optional `order` field (PositiveInt) to agent config so users and plugins can control Tab cycling order. Sorting in Agent.list() becomes: 1. Default agent first (unchanged) 2. By order ascending (new) 3. By name ascending (unchanged fallback) Fully backward-compatible — agents without `order` behave as before. Closes anomalyco#7372
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
The following comment was made by an LLM, it may be inaccurate: Found potential related PRs:
|
Closes #7372
Adds an optional
orderfield (PositiveInt) to agent config so users and plugins can control Tab cycling order instead of being forced into alphabetical sort.Currently
Agent.list()sorts agents alphabetically by name (after default agent). This breaks plugins that define multiple agents with a specific intended order. For example, oh-my-opencode defines Sisyphus → Hephaestus → Prometheus → Atlas, but alphabetical sort produces Atlas → Hephaestus → Prometheus → Sisyphus.The fix adds
order(positive integer, optional) to bothConfigAgent.InfoandAgent.Info. Sorting becomes:orderascending (new) — agents withoutordergetInfinityFully backward compatible — configs without
orderbehave exactly as before.Changes
packages/opencode/src/config/agent.ts: Addorderto AgentSchema + KNOWN_KEYSpackages/opencode/src/agent/agent.ts: Addorderto Info schema, merge logic, andsortBypackages/opencode/test/agent/agent.test.ts: Add 2 tests fororderordering, rename existing testHow verified
ordersort alphabetically as beforeNote: This is an improved version of #19127 with the unrelated test change removed, tests added, and Effect Schema patterns used (the codebase migrated from zod to Effect Schema).